package com.listener;

import com.event.MyEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;

@Component
public class MyEventListener implements ApplicationListener<MyEvent> {
    @Override
    public void onApplicationEvent(MyEvent myEvent) {
        System.out.println("事件监听器获取到MyEvent，睡眠当前线程2秒..");
        try { Thread.sleep(2000); } catch (InterruptedException e) { e.printStackTrace(); }
        System.out.println("睡醒了，MyEvent的message为"+myEvent.getMessage());
    }
}
